/**
 * 计算字符长度
 * 例子：
 *
 *   var stringLength = require("mlib/str/string-length");
 *   '🐴'.length;
 *   //=> 2
 *   
 *   stringLength('🐴');
 *   //=> 1
 *   
 *   stringLength('\u001b[1municorn\u001b[22m');
 *   //=> 7
 *
 */
'use strict';
var stripAnsi = require('strip-ansi');

module.exports = function (str) {
	var reAstral = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;

	return stripAnsi(str).replace(reAstral, ' ').length;
};